package com.tcd.outRisk.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tcd.outRisk.entity.ClaimMainInfo;
import com.tcd.outRisk.mapper.ClaimMainInfoMapper;
import com.tcd.outRisk.service.ClaimMainInfoService;
import com.tcd.service.CaseReportInfoservice;
import com.tcd.service.WarrantyInfoservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 赔案主档表 服务实现类
 * </p>
 *
 * @author Jarle
 * @since 2021-05-22
 */
@Service
public class ClaimMainInfoServiceImpl extends ServiceImpl<ClaimMainInfoMapper, ClaimMainInfo> implements ClaimMainInfoService {
    @Autowired
    ClaimMainInfoMapper mapper;
    @Autowired
    WarrantyInfoservice warrany;

    public int Clainmaincount(String id) {
        Map<String, Object> map = new HashMap<>();
        map.put("caseReportId", id);
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.allEq(map);
        ClaimMainInfo claim = mapper.selectOne(wrapper);
        return claim == null ? 0 : claim.getClaimmainId().intValue();
    }

    @Override
    public List<ClaimMainInfo> Clainmainlist(String uid) {
        return mapper.Clainmainlist(uid);
    }

    @Override
    public boolean Clainmainupdatestatus(String claimmainid, String claimmainstatus) {
        return mapper.Clainmainupdatestatus(claimmainid, claimmainstatus);
    }

    @Override
    public List<ClaimMainInfo> CLainmainlistsplice(int page, int pagesize) {
        List<ClaimMainInfo> list = mapper.CLainmainlistsplice(page, pagesize);
        for (ClaimMainInfo claim : list) {
            claim.setWarray(warrany.getWarrantyInfo(claim.getWarrantyId() + "", "", ""));
        }
        return list;
    }

    @Override
    public ClaimMainInfo getClaimmainone(String claimmainid) {
        return mapper.getClaimmainone(claimmainid);
    }
}
